package cn.bkrc.RedisTest;
import cn.bkrc.redis.RedisHashUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.HashMap;
import java.util.Map;


@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest
public class HashMapTest {
    @Autowired
    RedisHashUtils redisHashUtil;
    @Test
    public void testPut(){
        redisHashUtil.put("student","name","lisi");
    }

    @Test
    public void testPutAll(){
        Map<String, Object> map=new HashMap<>();
        map.put("age",23);
        map.put("sex","man");
        redisHashUtil.putAll("student",map);
    }

    @Test
    public void testEntries(){
        Map<Object, Object> student=redisHashUtil.entries("student");
        for (Map.Entry<Object, Object> entry: student.entrySet()){
            System.out.println(entry.getKey()+":"+entry.getValue());
        }
    }

    @Test
    public void delete(){
        redisHashUtil.delete("student","name","age");
    }

}
